package edu.cuit.avatar.factory;

import edu.cuit.avatar.service.BookService;
import edu.cuit.avatar.service.impl.BookServiceImplInFile;
import edu.cuit.avatar.service.impl.BookServiceImplInMemory;

/**
 * 简单工厂模式
 *      根据传入的参数决定创建哪种产品的实例
 *      违背了开闭原则
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/19 9:00
 */
public class SimpleFactory {
    private SimpleFactory(){

    }

    public static BookService create(String name){
        if("file".equals(name))
            return new BookServiceImplInFile();
        else if("memory".equals(name))
            return new BookServiceImplInMemory();

        return null;
    }
}
